<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>hello react</title>
    <style></style>
  </head>
  <body>
    <div id="test"></div>
    <!-- 引入react核心库 -->
    <script src="../js/react.development.js"></script>
    <!-- 引入react Dom库 用于支持 react操作dom-->
    <script src="../js/react-dom.development.js"></script>
    <!-- 引入babel 用于将 jsx 转为 js -->
    <script src="../js/babel.min.js"></script>

    <!-- 使用babel 转译jsx -->
    <script type="text/babel">
      // 1.创建组件
      class Demo extends React.Component {
        showData = () => {
          console.log(this.input1.value);
        };
        showData2 = () => {
          console.log(this.input2.value);
        };
        saveInput = (currentNode) => {
          this.input1 = currentNode;
        };
        render() {
          return (
            <div>
              <input
                ref={this.saveInput}
                type="text"
                placeholder="点击按钮提示数据"
              />
              <button onClick={this.showData}>点击提示左侧的数据</button>
              {/*jsx的注释方式*/}
              {/*<input
            ref={(currentNode) => (this.input2 = currentNode)}
            onBlur={this.showData2}
            type="text"
            placeholder="失去焦点提示数据"
            />*/}
            </div>
          );
        }
      }
      // 2.渲染虚拟DOM到页面
      ReactDOM.render(<Demo />, document.getElementById("test"));
    </script>
  </body>
</html>
